//map不会改变原数组，而是返回新的数组
//意思是map里面一般都要return，把新元素放到一个新数组中

let newArr4 = [1, 2, 3, 4, 5, 6]
newArr4.map((item) => {
     item=item+1
 })
console.log(newArr4)  //[ 1, 2, 3, 4, 5, 6 ]


let newArr = [1, 2, 3, 4, 5, 6]
let newArr1 = newArr.map(item => item * 2)
console.log(newArr1)


let newArr3 = [1, 2, 3, 4, 5, 6]
newArr3.map((item) => {
    item = item +1
})
console.log(newArr3)


let newArray2 = [
    {
        name: "单色凌",
        age: 31
    },
    {
        name: "徐良",
        age: 33
    },
    {
        name: "汪苏泷",
        age: 30
    }
]
newArray2.map((item) => {
    if (item.name == '单色凌') {
        item.age=18
    }
})
console.log(newArray2)
/*
[
  { name: '单色凌', age: 18 },
  { name: '徐良', age: 33 },
  { name: '汪苏泷', age: 30 }
]
*/